Get only bindings related to source/destination when checking if bindings exists or has been changed #43
+51
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @cyrilgdn,
In our rabbitmq setup we have some topic exchanges with thousands of bindings. Theses bindings are not managed by terraform but others are (exchange -> queue or exhange -> exchange bindings for example). Rabbitmq supports that amount of bindings quite well but the rabbitmq management api starts to be really slow to get the list of all bindings(GET
/api/bindings/vhost
).We reached a point where we start to have timeouts when we do
terraform plan
on any terraform with a rabbitmq_binding ressource because the provider does the same call to detect if the binding already exist and if it needs to be updated.After some investigations, the rabbitmq api does supports calls to specify the queue/exchanges involved in the binding(
/api/bindings/vhost/e/source/e/destination
and/api/bindings/vhost/e/exchange/q/queue
). Replacing the get all binding api call (/api/bindings/vhost
) by these, makes the call much lighter. Theses calls are implemented by ListExchangeBindingsBetween and ListQueueBindingsBetween in RabbitholeThis PR replace the 'list all bindings' call to more specific call depending on the destination type (queue or echange)
We did some tests in our setup and it seems to work nicely.
Note: I don't have experience in Go nor in terraform provider development, I'm open for any feedback/comment to improve the PR code to make better ;-)
Terraform Version
tested with terraform v1.0.3
Rabbitmq server version
3.8.21 (list all seems to be faster with higher version of rabbitmq server)
Affected Resource(s)
Please list the resources as a list, for example:
Debug Output
Error: unexpected EOF (due to the api call timeout)
Steps to Reproduce
terraform plan